<template>
    <div>
        <van-sticky>
            <van-nav-bar title="发表评论" left-text="返回" left-arrow @click-left="onClickLeft" right-text="发布"
                @click-right="onClickRight" />
        </van-sticky>
        <van-notice-bar left-icon="volume-o" text="为确保公正有效,非真实影评及作弊评分均不计入评分" />
        <div class="score">
            <div class="title">我的评分</div>
            <div class="score_num">
                <van-rate v-model="value" />
            </div>
        </div>
        <van-divider />
        <div class="comments">
            <textarea name="" id="" cols="30" rows="10" v-model="text" placeholder="写几句评价"></textarea>
        </div>
    </div>
</template>
<script>
import nav from "@/mixin/nav";
import { writeComments } from "@/service/movie/movieService";
export default {
    mixins: [nav],
    data() {
        return {
            value: 0,
            text: ""
        }
    },
    methods: {
        onClickLeft() {
            this.$router.go(-1);
        },
        async onClickRight() {
            let id = this.$route.params.id;
            let { data } = await writeComments({
                movieId: id,
                score: this.value,
                content: this.text
            })
            console.log(data);
            if (data.code == 200) {
                this.$toast.success("发表成功!");
                this.$router.go(-1);
            }
        }
    }
}


</script>
<style scoped lang="scss">
.score {
    line-height: 50px;

    .title {
        text-align: center;
    }

    .score_num {
        text-align: center;
    }
}

.comments {
    width: 100%;

    textarea {
        padding: 10px;
        resize: none;
        width: 100%;
        border: none;
    }

}
</style>